Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(licenses): Add validation to license requests and code refactor #82

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

deo002
Copy link
Collaborator

@deo002 deo002 commented Sep 9, 2024

Changes

  • Add validation to License APIs(i.e. rf_risk value should be from 0-5,set some values that are required, do not allow empty strings for rf_shortname, rf_fullname etc)
  • Code refactor:
    • Simplify code by using pointer values for struct fields of LicenseDB and LicenseUpdateJSONSchema. Previously, the reason for using generics such as OptionalData was to differentiate between actual zero values and undefined values in json(for datatypes such as bool, on parsing json, the value is populated as false(zero value) for both the cases in struct). Now, the default value will be nil for undefined and false when value is actually false. This will help in eliminating OptionalData and NullableAndOptionalData wrappers from codebase. No more need of using maps for updates and validation can be done in BeforeSave hook(hooks do not run for maps in GORM).
    • Reuse LicenseDB struct for Import, POST and Export and remove the redundant data types used for them.

Submitter Checklist

  • Includes tests (if there is a feature changed/added)
  • Includes docs ( if changes are user facing)
  • I have tested my changes locally.

References

image

@deo002 deo002 requested a review from GMishx September 9, 2024 05:38
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good.

@deo002 deo002 requested a review from GMishx September 25, 2024 05:43
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good.

Tested, working as expected.

@GMishx GMishx merged commit 1a392a1 into fossology:main Sep 26, 2024
7 checks passed
@GMishx GMishx deleted the refactor/licenses branch September 26, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants